package com.jhhc.WaterQuality.Calculate.Forecast.service.impl;

import com.jhhc.WaterQuality.Calculate.Forecast.entity.BDMS_YB_RESULT_M;
import com.jhhc.WaterQuality.Calculate.Forecast.dao.BDMS_YB_RESULT_MMapper;
import com.jhhc.WaterQuality.Calculate.Forecast.service.BDMS_YB_RESULT_MService;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;

import javax.annotation.Resource;

/**
 * (BdmsYbResultM)表服务实现类
 *
 * @author makejava
 * @since 2023-06-20 09:24:05
 */
@Service("bdmsYbResultMService")
public class BDMS_YB_RESULT_MServiceImpl implements BDMS_YB_RESULT_MService {
    @Resource
    private BDMS_YB_RESULT_MMapper bdmsYbResultMDao;

    /**
     * 通过ID查询单条数据
     *
     * @param cschemeid 主键
     * @return 实例对象
     */
    @Override
    public BDMS_YB_RESULT_M queryById(String cschemeid) {
        return this.bdmsYbResultMDao.queryById(cschemeid);
    }

    /**
     * 分页查询
     *
     * @param bdmsYbResultM 筛选条件
     * @param pageRequest   分页对象
     * @return 查询结果
     */
    @Override
    public Page<BDMS_YB_RESULT_M> queryByPage(BDMS_YB_RESULT_M bdmsYbResultM, PageRequest pageRequest) {
        long total = this.bdmsYbResultMDao.count(bdmsYbResultM);
        return new PageImpl<>(this.bdmsYbResultMDao.queryAllByLimit(bdmsYbResultM, pageRequest), pageRequest, total);
    }

    /**
     * 新增数据
     *
     * @param bdmsYbResultM 实例对象
     * @return 实例对象
     */
    @Override
    public BDMS_YB_RESULT_M insert(BDMS_YB_RESULT_M bdmsYbResultM) {
        this.bdmsYbResultMDao.insert(bdmsYbResultM);
        return bdmsYbResultM;
    }

    /**
     * 修改数据
     *
     * @param bdmsYbResultM 实例对象
     * @return 实例对象
     */
    @Override
    public BDMS_YB_RESULT_M update(BDMS_YB_RESULT_M bdmsYbResultM) {
        this.bdmsYbResultMDao.update(bdmsYbResultM);
        return this.queryById(bdmsYbResultM.getCschemeid());
    }

    /**
     * 通过主键删除数据
     *
     * @param cschemeid 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(String cschemeid) {
        return this.bdmsYbResultMDao.deleteById(cschemeid) > 0;
    }
}
